/**
  ******************************************************************************
  * @author     Chris
  * @since      2024/6/10 10:36
  *
  * @file       hd_oled_protocol.h
  * @brief      Header file of OLED protocol hardware driver.
  *
  * @note       This file contains the OLEDProtocol object declaration.
  *
  * @warning    None.
  ******************************************************************************
  * Change Logs:
  *   Date           Author       Notes
  *   2024/6/10      Chris        the first version
  *
  ******************************************************************************
  */

#ifndef JLC_SKY_OLED_PROTOCOL_H
#define JLC_SKY_OLED_PROTOCOL_H

#include "stm32f4xx.h"

struct OLEDProtocolVtbl;

// Object properties
typedef struct {
    struct OLEDProtocolVtbl *vptr;
} OLEDProtocol;

// Object virtual table
struct OLEDProtocolVtbl {
    void (*init)(const OLEDProtocol *this);

    void (*write)(const OLEDProtocol *this,
                  uint8_t salveAddress, uint16_t regAddress, uint8_t *dat, uint8_t len);
};

// Object constructor and member function
void OLEDProtocol_constructor(OLEDProtocol *this);

static inline void OLEDProtocol_init(const OLEDProtocol *this) {
    this->vptr->init(this);
}

static inline void OLEDProtocol_write(const OLEDProtocol *this,
                                      uint8_t salveAddress, uint16_t regAddress, uint8_t *dat, uint8_t len) {
    this->vptr->write(this, salveAddress, regAddress, dat, len);
}

#endif // JLC_SKY_OLED_PROTOCOL_H
